package de.tabuma.sso.logik;

import java.security.*;
import java.util.logging.*;
/**
 * @author $Author: alefen $
 * @version $Revision: 1.1.1.1.2.1 $
 * @since $Date: 2010/01/08 10:03:24 $
 */
public class Lib {
    
    private static final Logger log = Logger.getLogger(Lib.class.getName());
    
    private static final String ALGORITHM = "MD5";
    
    public static String toMD5(String a) {
        try {
            MessageDigest md = MessageDigest.getInstance(ALGORITHM);
            byte[] defaultBytes = a.getBytes();
            md.reset();
            md.update(defaultBytes);
            byte messageDigest[] = md.digest();
            StringBuffer hexString = new StringBuffer();
            for (int i=0;i<messageDigest.length;i++) {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }
            return hexString.toString();
        }
        catch(Exception e) {

        }
        return "";
    }
}
